﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Login : Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            ServiceReference.ServiceClient service = new ServiceReference.ServiceClient();
            string u = UsernameTextBox.Text;
            string p = PasswordTextBox.Text;
            if (service.checkLogin(u, p) != null)
            {
                Session["Login"] = service.checkLogin(u, p);
                Session["Booking"] = new ServiceReference.Booking();
                ((ServiceReference.Booking)Session["Booking"]).accountId = ((ServiceReference.Account)Session["Login"]).accountId;
                ValidationLabel.Text = "DA";
                Server.Transfer("UserPanel.aspx");

            }
            else
            {
                ValidationLabel.Text = "Your username or password are wrong.";
            }
            service.Close();
        }
    }
}
